Add patch to fix rounding errors
authorGert Wollny <gewo@debian.org>
Thu, 22 Jun 2017 07:54:59 +0000 (07:54 +0000)
committerGert Wollny <gewo@debian.org>
Thu, 22 Jun 2017 07:54:59 +0000 (07:54 +0000)
debian/patches/09_round_time.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/09_round_time.patch b/debian/patches/09_round_time.patch
new file mode 100644 (file)
index 0000000..f4f3464
--- /dev/null
@@ -0,0 +1,18 @@
+Author: Gert Wollny <gewo@debian.org>
+Description: work around numerical instability by rounding the time in seconds 
+ to the six decimal points supported in dicom
+Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859204
+
+--- a/ofstd/libsrc/oftime.cc
++++ b/ofstd/libsrc/oftime.cc
+@@ -491,6 +491,10 @@
+ {
+     /* compute number of seconds since 00:00:00 */
+     double result = ((OFstatic_cast(double, hour) - timeZone) * 60 + OFstatic_cast(double, minute)) * 60 + second;
++
++    /* Dicom supports only six decimal digits, but floating point operations might introduce errors */
++    result = round(result * 1000000.0) / 1000000.0; 
++    
+     /* normalize the result to the range [0.0,86400.0[ */
+     if (normalize)
+         result -= OFstatic_cast(double, OFstatic_cast(unsigned long, result / 86400) * 86400);
index c7ae91036618d8a106c41d9e32e59d133ee5a30b..0ae3d31b61943d786273e122fe4a018625df1cc3 100644 (file)
@@ -6,3 +6,4 @@
 06_soversion_abi.patch
 07_dont_export_all_executables.patch
 08_remove_system_processor.patch
+09_round_time.patch